/*
	Interface对象的pause方法
	pause事件
*/

var readline = require('readline');

var r1 = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	completer: function(line) {
		var completions = 'help error quit apple application'.split(' ');
		var hits = completions.filter(function(c) {
			return c.indexOf(line) == 0;
		});
		// 如果未发现匹配字符串则返回所有用于Tab补全的字符串
		// return [hits.length ? hits : completions, line];
		// 未发现，不返回；发现，返回Tab补全字符串
		return [hits, line];
	}
});

r1.on('line', function(line) {
	if (line == 'exit' || line == 'quit' || line == 'q')
		r1.close();
	else if (line == 'pause')
		r1.pause();
	else
		console.log('您输入了：' + line);
});

r1.on('pause', function() {
	console.log('暂停读取数据');
});

r1.on('close', function() {
	console.log('行数据读取操作被终止');
});